package com.lambda.demo.models;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

public class AuthorsData {
  public static List<Author> getAuthors() {
    //添加作者
    Author author1 = new Author(1l,"余华", 63, "简介", null);
    Author author2 = new Author(2l,"莫言", 69, "简介", null);
    Author author3 = new Author(3l,"曹雪芹", 310, "简介", null);
    Author author4 = new Author(4l,"施耐庵", 728, "简介", null);
    Author author5 = new Author(5l,"刘慈欣", 60, "简介", null);

    //书籍列表
    List<Book> books1 = new ArrayList<Book>();
    List<Book> books2 = new ArrayList<Book>();
    List<Book> books3 = new ArrayList<Book>();
    List<Book> books4 = new ArrayList<Book>();
    List<Book> books5 = new ArrayList<Book>();

    books1.add(new Book(1l,"活着", "现代小说,小说", 7, "简介"));
    books1.add(new Book(2l,"许三观卖血记", "现代小说,小说", 8, "简介"));
    books1.add(new Book(3l,"兄弟", "现代小说,小说", 5, "简介"));

    books2.add(new Book(11l,"蛙", "现代小说,小说", 8, "简介"));
    books2.add(new Book(12l,"檀香刑", "现代小说,小说", 8, "简介"));
    books2.add(new Book(13l,"生死疲劳", "现代小说,小说,魔幻现实主义小说", 7, "简介"));

    books3.add(new Book(21l,"红楼梦", "古典小说,小说", 10, "简介"));

    books4.add(new Book(31l,"水浒传", "古典小说,小说", 9, "简介"));

    books5.add(new Book(41l,"三体-地球往事", "科幻小说,小说", 8, "简介"));
    books5.add(new Book(42l,"三体-黑暗深林", "科幻小说,小说", 8, "简介"));
    books5.add(new Book(43l,"三体-死生永生", "科幻小说,小说", 8, "简介"));
    books5.add(new Book(44l,"流浪地球", "科幻小说,小说", 7, "简介"));

    author1.setBooks(books1);
    author2.setBooks(books2);
    author3.setBooks(books3);
    author4.setBooks(books4);
    author5.setBooks(books5);

    //将author添加到一个list
    List<Author> authors = new ArrayList<Author>();
    authors.add(author1);
    authors.add(author2);
    authors.add(author3);
    authors.add(author4);
    authors.add(author5);
    return authors;
  }

  public static List<Author> getAuthorsWithDuplicates() {
    //添加作者
    Author author1 = new Author(3l,"曹雪芹", 310, "简介", null);
    Author author2 = new Author(3l,"曹雪芹", 310, "简介", null);
    Author author3 = new Author(3l,"曹雪芹", 310, "简介", null);
    Author author4 = new Author(3l,"曹雪芹", 310, "简介", null);

    //将author添加到一个list
    List<Author> authors = new ArrayList<Author>();
    authors.add(author1);
    authors.add(author2);
    authors.add(author3);
    authors.add(author4);
    return authors;
  }

  public static Optional<List<Author>> getAuthorsOptional() {
    //添加作者
    Author author1 = new Author(1l,"余华", 63, "简介", null);
    Author author2 = new Author(2l,"莫言", 69, "简介", null);
    Author author3 = new Author(3l,"曹雪芹", 310, "简介", null);
//        Author author8 = new Author(4l,"施耐庵2", 728, "简介", null);
    Author author4 = new Author(4l,"施耐庵", 728, "简介", null);
    Author author5 = new Author(5l,"刘慈欣", 60, "简介", null);

    //加入一些重复的作家
    Author author6 = new Author(3l,"曹雪芹", 310, "简介", null);
    Author author7 = new Author(5l,"刘慈欣", 60, "简介", null);


    //书籍列表
    List<Book> books1 = new ArrayList<Book>();
    List<Book> books2 = new ArrayList<Book>();
    List<Book> books3 = new ArrayList<Book>();
    List<Book> books4 = new ArrayList<Book>();
    List<Book> books5 = new ArrayList<Book>();

    books1.add(new Book(1l,"活着", "现代小说,小说", 7, "简介"));
    books1.add(new Book(2l,"许三观卖血记", "现代小说,小说", 8, "简介"));
    books1.add(new Book(3l,"兄弟", "现代小说,小说", 5, "简介"));

    books2.add(new Book(11l,"蛙", "现代小说,小说", 8, "简介"));
    books2.add(new Book(12l,"檀香刑", "现代小说,小说", 8, "简介"));
    books2.add(new Book(13l,"生死疲劳", "现代小说,小说,魔幻现实主义小说", 7, "简介"));

    books3.add(new Book(21l,"红楼梦", "古典小说,小说", 10, "简介"));

    books4.add(new Book(31l,"水浒传", "古典小说,小说", 9, "简介"));

    books5.add(new Book(41l,"三体-地球往事", "科幻小说,小说", 8, "简介"));
    books5.add(new Book(42l,"三体-黑暗深林", "科幻小说,小说", 8, "简介"));
    books5.add(new Book(43l,"三体-死生永生", "科幻小说,小说", 8, "简介"));
    books5.add(new Book(44l,"流浪地球", "科幻小说,小说", 7, "简介"));

    author1.setBooks(books1);
    author2.setBooks(books2);
    author3.setBooks(books3);
    author6.setBooks(books3);
    author4.setBooks(books4);
    author5.setBooks(books5);
    author7.setBooks(books5);

    //将author添加到一个list
    List<Author> authors = new ArrayList<Author>();
    authors.add(author1);
    authors.add(author2);
    authors.add(author3);
    authors.add(author4);
    authors.add(author5);
    authors.add(author6);
    authors.add(author7);
    return Optional.ofNullable(authors);
  }

  public static Optional<Author> getAuthorOptinal() {
    //添加作者
    Author author = new Author(1l,"余华", 63, "简介", null);

    //书籍列表
    List<Book> books = new ArrayList<Book>();
    books.add(new Book(1l,"活着", "现代小说,小说", 7, "简介"));
    books.add(new Book(2l,"许三观卖血记", "现代小说,小说", 8, "简介"));
    books.add(new Book(3l,"兄弟", "现代小说,小说", 5, "简介"));
    author.setBooks(books);
    return Optional.ofNullable(author);
  }

  public static Optional<List<Author>> getEmptyAuthors() {
    return Optional.ofNullable(null);
  }
}
